<?php

class FileUtility
{
    public static function convertFromArrayToCSV(array $data)
    {
        if(empty($data))
        {
            return '';
        }

        // headers
        $headers = array_keys($data[0]);
        $csv = '"'.implode('","', $headers).'"'."\n";

        // data
        foreach($data as $row)
        {
            $csv .= '"'.implode('","', $row).'"'."\n";
        }

        return $csv;
    }
}